package at.hockey.ticker;

import java.util.LinkedList;
import java.util.ListIterator;

public class MatchDetails{

	private String mDateTime, mTeam1, mTeam2, mText1, mText2, mText3;
	private LinkedList<MatchDetailsEntry> mEntries;
	
	public MatchDetails(String datetime, String team1, String team2, String text1, String text2, String text3){
		this.mDateTime = datetime;
		this.mTeam1 = team1;
		this.mTeam2 = team2;
		this.mText1 = text1;
		this.mText2 = text2;
		this.mText3 = text3;
		this.mEntries = new LinkedList<MatchDetailsEntry>();
	}
	
	public String getDateTime(){
		return this.mDateTime;
	}
	
	public String getTeam1(){
		return this.mTeam1;
	}
	
	public String getTeam2(){
		return this.mTeam2;
	}
	
	public String getText1(){
		return this.mText1;
	}

	public String getText2(){
		return this.mText2;
	}

	public String getText3(){
		return this.mText3;
	}
	
	public LinkedList<MatchDetailsEntry> getMatchDetailsEntries(){
		return this.mEntries;		
	}
	
	public String getScore(){

		int scoreTeam1 = 0;
		int scoreTeam2 = 0;
		MatchDetailsEntry mde = null;
		
		ListIterator<MatchDetailsEntry> itr = mEntries.listIterator();
	    while(itr.hasNext()){
	  
	    	mde = itr.next();
	    	if(mde.getType().equals("EQ")){
	    		if(mde.getTeam().equals(this.getTeam1())){
	    			scoreTeam1++;
	    		}
	    		else{
	    			scoreTeam2++;
	    		}
	    	}
	    }
		
		return Integer.toString(scoreTeam1) + ":" + Integer.toString(scoreTeam2);
	}
	
	public void setText1(String text1){
		this.mText1 = text1;
	}

	public void setText2(String text2){
		this.mText2 = text2;
	}
	
	public void setText3(String text3){
		this.mText3 = text3;
	}
	
	public void addMatchDetailsEntry(MatchDetailsEntry entry){
		this.mEntries.add(0, entry);		
	}
}
